package com.newthread.jdp.model;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import org.apache.struts2.json.annotations.JSON;


@Entity
public class UserInfo {
	private int id;
	private String imageUrl;
	private String introduce;
	private String name;
	private String passWord;
	private String studentId;
	private String user_id, channel_id;
	private List<Tag> tags;
	private List<Message> pushMessage;
	private List<Message> receveMessage;

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "User_Tag", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "tag_id") })
	 @JSON(serialize = false)
	public List<Tag> getTags() {
		return tags;
	}

	public void setTags(List<Tag> tags) {
		this.tags = tags;
	}

	 @JSON(serialize = false)
	public String getUser_id() {
		return user_id;
	}

	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}

	 @JSON(serialize = false)
	public String getChannel_id() {
		return channel_id;
	}

	public void setChannel_id(String channel_id) {
		this.channel_id = channel_id;
	}

	private UserType userType;

	@Enumerated(EnumType.STRING)
	public UserType getUserType() {
		return userType;
	}

	public void setUserType(UserType userType) {
		this.userType = userType;
	}

	public UserInfo(String studentId, String passWord) {
		this.studentId = studentId;
		this.passWord = passWord;

	}

	public UserInfo(String studentId) {
		this.studentId = studentId;
	}

	@Id
	@GeneratedValue
	 @JSON(serialize = false)
	public int getId() {
		return id;
	}

	@JoinColumn(name = "userImagePath")
	public String getImageUrl() {
		return imageUrl;
	}

	public String getIntroduce() {
		return introduce;
	}

	public String getName() {
		return name;
	}

	 @JSON(serialize = false)
	public String getPassWord() {
		return passWord;
	}

	public String getStudentId() {
		return studentId;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}

	public void setStudentId(String studentId) {
		this.studentId = studentId;
	}

	private UserInfo() {

	}
	@OneToMany(fetch=FetchType.LAZY,mappedBy="pushUser")
	public List<Message> getPushMessage() {
		return pushMessage;
	}

	public void setPushMessage(List<Message> pushMessage) {
		this.pushMessage = pushMessage;
	}
	@ManyToMany(fetch=FetchType.LAZY)
	@JoinTable(name = "User_receveMessage", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "receveMessage_id") })
	public List<Message> getReceveMessage() {
		return receveMessage;
	}

	public void setReceveMessage(List<Message> receveMessage) {
		this.receveMessage = receveMessage;
	}

}
